# -*- coding:utf-8 -*-
# 装饰器的本质是一个闭包
# 写法结构：
# def external(func):
#     def inside():
#         print("开启外挂")
#         func()                  # 被装饰的函数
#         print("关闭外挂")
#     return inside
#
#
# @external
# def play_lol():
#     print("欢迎来到英雄联盟")
#
#
# @external
# def play_wz():
#     print("欢迎来到王者荣耀")
#
#
# play_lol()
# play_wz()


# 装饰器的参数
# def external(func):
#     def inside(*args, **kwargs):
#         print("开启外挂")
#         func(*args, **kwargs)                  # 被装饰的函数
#         print("关闭外挂")
#     return inside
#
#
# @external
# def play_lol(usename, passward):
#     print(f"账号：{usename}\t密码:{passward}\t{usename}登陆成功 -- 欢迎来到英雄联盟")
#
#
# @external
# def play_wz(usename, passward, hero):
#     print(f"账号：{usename}\t密码: {passward}\t{usename}登陆成功\t请选择英雄：{hero}  --欢迎来到王者荣耀")
#
#
# play_lol("123456", "678901")
# play_wz("147258", "203567", "李白")


# 返回值
def external(func):
    def inside(*args, **kwargs):
        print("开启外挂")
        ret = func(*args, **kwargs)  # 被装饰的函数
        print("关闭外挂")
        return ret

    return inside


# @external
def play_lol(usename, passward):
    print(f"账号：{usename}\t密码:{passward}\t{usename}登陆成功 -- 欢迎来到英雄联盟")


@external
def play_wz(usename, passward, hero):
    print(f"账号：{usename}\t密码: {passward}\t{usename}登陆成功\t请选择英雄：{hero}  --欢迎来到王者荣耀")
    return "无尽战刃"


# play_lol("123456", "678901")
demo = play_wz("147258", "203567", "李白")
print(demo)


# 原来的游戏不带外挂
# 将原来的游戏包装一层外挂，之后我们在玩
